import { Component, OnInit } from '@angular/core'
import { map } from 'rxjs/operators'

import { IQRRouteOfStore } from '@shared/interfaces/store'
import { IChannelMap } from '../../components/channels-switcher/channels-switcher.interface'
import { StoreBaseChannelComponent } from './store-base-channel.component'

@Component({
  selector: 'app-store-open-channel',
  templateUrl: './store-open-channel.component.html',
  styles: [],
})
export class StoreOpenChannelComponent extends StoreBaseChannelComponent implements OnInit {
  ngOnInit() {
    this.channelsMap$ = this.route.queryParams.pipe(
      map(params => {
        this.paymentBrand = params.paymentBrand
        const route: IQRRouteOfStore = {
          paymentBrand: this.paymentBrand,
          chanCode: this.paymentBrand,
        }
        const channelsMap: IChannelMap = { [this.paymentBrand]: route }
        return channelsMap
      }),
    )
  }
}
